<?php 
include('./fun.php');include('./hd_fun.php');
$conn=my_sql($cfg);
$re=user_login();
if($re['err']=='no_login'){direct('login.php?t='.time());exit;}
if($re['err']!='ok'){die($re['err']);}
$user=$re['user'];
$shop_id=$re['shop_id'];
$shop=get_shop();
$set=get_set();

$sql='select * from '.$cfg['e'].'users where is_emp="'.$shop['id'].'"  ';
$state=g('state');
if($state){
if($state=='stop'){$sql.=' and emp_state=0 ';}else{$sql.=' and emp_state=1 ';}
}

$sql.=' order by id desc';
$l=db($sql);


?>
<style>

</style>
<hh><b>雇员管理</b></hh>
<mm>
<?php 
$url=url_get(['page','state']);
echo '<index>';
if($state){echo '<a class="m" href="?'.$url.'">全部</a>';}
echo '<a class="m '.($state==1?'select':'').'" href="?'.$url.'&state=1">已审核</a>';
echo '<a class="m '.($state=='stop'?'select':'').'" href="?'.$url.'&state=stop">待审核</a>';
echo '</index>';

if($l){
echo '<table>';    
th(['','昵称','电话','操作']);
foreach($l as $v){
echo '<tr>';
echo '<td><img src="'.$v['logo'].'" style="width:40px;border-radius:50%"></td>';
echo '<td>'.base64($v['nickname']).'</td>';
echo '<td>'.$v['phone'].'</td>';
echo '<td>
'.($v['emp_state']==1?'<a onclick="emp_state($(this))" i="'.$v['id'].'" val="stop">禁用帐户</a>':'<a onclick="emp_state($(this))" i="'.$v['id'].'" val="1">审核通过</a>').'
</td>';
echo '</tr>';
}
echo '</table>';
}else{no_data('您还没有雇员');}


?>



</mm>





<script>
function emp_state(o){
var val=o.attr('val');if(val!='stop'){val=1;}
var id=o.attr('i');if(!id){msg('请指定用户');return;}
var data={state:val}
post('emp_state',data,id,function(res){
    main_load();
    
})
}




</script>